package kr.hkit.calendarproject12.Adapter;

import java.util.ArrayList;

import kr.hkit.calendarproject12.R;
import kr.hkit.calendarproject12.DAO.DAO;
import kr.hkit.calendarproject12.DTO.MyItem;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

//날짜를 클릭했을때, 스케쥴이 있을시 ListView에 붙일 해당 스케쥴 어댑터
public class TodayListAdapter extends BaseAdapter {
	Context context;
	LayoutInflater inflate;
	int layout;
	DAO dao;
	ArrayList<MyItem> tList;	//해당정보 DB에서 select. DAO에서 처리. 타이틀을 select해서 setText함
	
	public TodayListAdapter(Context context, ArrayList<MyItem> tList, int layout) {
		this.context = context;
		this.tList =  tList;
		this.inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.layout = layout;
		dao = DAO.open(context);
	}
	
	@Override
	public int getCount() {
		return tList.size();
	}

	@Override
	public Object getItem(int position) {
		return tList.get(position).getTitle();
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final int pos = position;
		if(convertView == null){
			convertView = inflate.inflate(layout, parent, false);
		}
		
		TextView titleSec = (TextView) convertView.findViewById(R.id.todaylisttitle);
		titleSec.setText(tList.get(position).getTitle());
					
		return convertView;
	}

}
